import 'package:chaos_flutter3/app/dtos/ZyyShareDoc.dart';
import 'package:chaos_flutter3/chaos/Data.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class InfoPage extends HookWidget {
  final String arguments;

  const InfoPage({required this.arguments, Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => SingleChildScrollView(

      child: Column(
        children: [buildInfo()],
      ));

  buildInfo() => Container(
    color: Colors.lightGreen,
    child: FutureBuilder<String>(
          future: loadData(),
          builder: (BuildContext context, AsyncSnapshot snapshot) => Data()
              .futureBuilding(
                  context,
                  snapshot,
                  Text("Contents: ${snapshot.data}",
                      textAlign: TextAlign.center,
                      overflow: TextOverflow.clip,
                      style: const TextStyle(fontStyle: FontStyle.italic))),
        ),
      );

  Future<String> loadData() async =>
      ZyyShareDoc.fromJson(await Data().one('zyyShareDoc', arguments)).username;
}
